//
//  BaseViewController.m
//  Weibo
//
//  Created by student on 16/4/22.
//  Copyright © 2016年 Mcc. All rights reserved.
//

#import "BaseViewController.h"

#import "VisitorView.h"
#import "OAuthViewController.h"



@implementation BaseViewController

//加载视图的时候根据用户是否登录,判断加载哪个界面
-(void)loadView
{
       if ([[UserAccount sharedUserAccount] isLogined])//用户已登录显示正常tableView
    {
        [super loadView];
    }
    else
    {
        //未登录就加载访客视图
        VisitorView *view=[[VisitorView alloc]init];
        self.view=view;
        self.visitorView=view;
        
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(registerBtnPressed:)];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登录" style:UIBarButtonItemStylePlain target:self action:@selector(loginBtnPressed:)];
    }
}

- (void)registerBtnPressed:(id)sender
{
    
}

- (void)loginBtnPressed:(id)sender
{
    OAuthViewController *authVC = [[OAuthViewController alloc] init];
    UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:authVC];
    [self presentViewController:navi animated:YES completion:nil];
}


@end
